﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using WGMClient.WGMSvc;
using System.ServiceModel;
using System.Threading;

namespace WGMClient.Core
{
    [CallbackBehaviorAttribute(UseSynchronizationContext = false)]
    public class ConnectionHandler : WGMSvc.IWGMServiceCallback
    { 
        public void HandleClientMessage(WGMMessage message)
        {
            HelperClasses.Registry.MainWindow.HandleMessage(message);
        }

        public void Ping()
        {
            //HelperClasses.Registry.MainWindow.HandleMessage("Ping from server");
        }
        internal void SendMessageToServer(WGMMessage message)
        {
            ThreadPool.QueueUserWorkItem
            (
                delegate
                {
                    try
                    {
                        HelperClasses.Registry.WGMSvc.HandleServerMessage(message);                        
                    }
                    catch
                    {
                        
                    }
                }
            );
        }
    }
}
